package com.threeti.mecool.core.infrastructure.persistence.message;

import java.math.BigDecimal;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.threeti.mecool.core.domain.model.message.SystemMessage;

public interface SystemMessageRepository extends JpaRepository<SystemMessage, Long> {
    Page<SystemMessage> findByReceiverAndReceived(String receiver, int received, Pageable pageable);

    Page<SystemMessage> findByReceiver(String receiver, Pageable pageable);


    @Query(nativeQuery=true,value="select count(0) from DM_SYSTEM_MESSAGE where receiver = ?1 and received = 0")
    BigDecimal countUnReadSysMessageNum(String receiver);
}
